#include "SOMNeuron.h"

SOMNeuron::SOMNeuron(int virtualPosX, int virtualPosY, Vector2 initW, shared_ptr<ITransferFunctionBase> & fTransFunc) :
	m_VirPosX(virtualPosX),
	m_VirPosY(virtualPosY),
	m_bFire(false),
	m_W(initW),
	m_Y(0.0),
	m_TransFunc(fTransFunc)
{
}

double SOMNeuron::Execute(const Vector2 & Input)
{
	this->m_Y = this->m_W.Dot(Input);

	if (this->m_TransFunc)
	{
		this->m_Y = this->m_TransFunc->Do(this->m_Y);
	}

	return this->m_Y;
}

Vector2 & SOMNeuron::GetWeightVector()
{
	return this->m_W;
}

void SOMNeuron::SetWeightVector(const Vector2 & newW)
{
	this->m_W = newW;
}

void SOMNeuron::CopyWeightArray(double * buffer) const
{
	for (int i = 0; i < this->m_W.GetDimesion(); i++)
		buffer[i] = this->m_W.GetData()[i];
}

void SOMNeuron::SetFireState(bool bFireState)
{
	this->m_bFire = bFireState;
}

bool SOMNeuron::IsFireState() const
{
	return this->m_bFire;
}

int SOMNeuron::GetVirtualPosX() const
{
	return this->m_VirPosX;
}

int SOMNeuron::GetVirtualPosY() const
{
	return this->m_VirPosY;
}